<?php

namespace app\command;

use Illuminate\Support\Str;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Output\OutputInterface;
use app\service\MediaAnalyzeService;


class TestCmd extends Command
{
    protected static $defaultName = 'test:cmd';
    protected static $defaultDescription = 'test cmd';

    /**
     * @return void
     */
    protected function configure()
    {
        $this->addArgument('name', InputArgument::OPTIONAL, 'Name description');
    }

    /**
     * @param InputInterface $input
     * @param OutputInterface $output
     * @return int
     */
    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $toolService = new MediaAnalyzeService();
        $mediaResult = $toolService->analyze('https://v.douyin.com/ihhKJEJo/');
        foreach ($mediaResult as $v){
            //$output->writeln("content:" . $v);
            if(Str::startsWith($v,'https://www.douyin.com/aweme')){
                $output->writeln("content:" . $v);
            }
        }
        return self::SUCCESS;
    }
}
